<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateTableActivityProductMappings extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('activity_product_mappings', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger("activityId")->comment("活动id")->default(0);
            $table->unsignedBigInteger("productId")->comment("菜品id")->default(0);
            $table->unsignedTinyInteger("type")->comment("类型 1 - 下单适用菜品 2 - 下单满赠菜品")->default(0);
            $table->unsignedInteger("giveNum")->comment("赠品数量(type = 2 时使用)")->default(1);
            $table->unsignedInteger("giveStockRuleType")->comment("赠菜库存规则(type = 2 时使用) 0 - 不限制 1 - 数量限制")->default(0);
            $table->integer("stockNum")->comment("库存数量(type = 2 时使用)")->default(0);
            $table->unsignedInteger('createdByUid')->default(0)->comment('创建人');
            $table->unsignedInteger('updatedByUid')->default(0)->comment('更新人');
            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('updatedAt')->default(0)->comment('修改时间');
            $table->tinyInteger("isDeleted")->default(0)->comment("是否删除,0:未删除,1:已删除");
            $table->index(["activityId", "isDeleted"], "idx_activityId_isDeleted");
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('activity_product_mappings');
    }
}
